package request

import (
	"log"
	"net/http"

	"github.com/PuerkitoBio/goquery"
)

type Request struct {
}

func (r *Request) GetHtmlData() string {
	url := "https://nvd.nist.gov/vuln/detail/CVE-2024-23940"
	resp, err := http.Get(url)
	if err != nil {
		log.Fatalf("get resp by url %s error", url)
	}
	defer resp.Body.Close()
	doc, err := goquery.NewDocumentFromReader(resp.Body)
	if err != nil {
		log.Fatal("parse HTML error: " + err.Error())
	}
	var description string
	doc.Find("[data-testid='vuln-description']").Each(func(i int, s *goquery.Selection) {
		description = s.Text()
	})
	return description
}
